

var oshClient = new ActiveXObject("OSH.Client");

oshClient.Connect("");

if(oshClient.State == 0)
{
	oshClient.Disconnect();

	WScript.echo("Can't connect to the OSH Host.");
	WScript.quit();
}


var oshSource = new ActiveXObject("OSH.Source");
oshSource.Open(oshClient.SourceName);

var bitmap = null;
try
{
	bitmap = oshSource.GetVisibleBitmap();
}
catch(e)
{
	try
	{
		bitmap = oshSource.WaitForBitmap(30000);
	}
	catch(e)
	{
		WScript.echo("Can't get OSH bitmap.");
		WScript.quit();
	}
}

var filePath = "C:\\osh - " + new Date(bitmap.Created).toGMTString().replace(/:/g, " ") + ".bmp";
bitmap.Save(filePath);


WScript.echo("Created \"" + filePath + "\" file.");

